package com.example.Mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.example.pojo.oderfrom;
import com.example.pojo.oderfromcong;


public interface oderfromMapper {
	
		//查询主表（分页1）
		@Select("select * from oderfrom order by billno limit #{0},#{1}")
		public List<oderfrom> querybypage(@Param("0")int pagenum,@Param("1")int pagesize);
		
		//查询主表（分页1）
		@Select("select * from oderfromcong where billno=#{billno}")
		public List<oderfromcong> querybypage1(@Param("billno")String billno);
		
		//通过id查询
		@Select("select * from oderfrom where billno=#{billno}")
		public int querybyid(@Param("billno")String id);
		
		//查询数量
		@Select("select count(*) from oderfrom")
		public int querycount();
		
		//新增主表
		@Insert("insert into test.oderfrom (Customerid, Billdate, Billno, Currid, Shifoushenhe, Sumtotal, Priceoftax, Billstatus,"
				+ " Exchrate, Maker, Salesid,Permitter, Departname, Projectid)  values(#{customerid},#{Billdate},#{billno},#{currid},"
				+ "#{shifoushenhe},#{sumtotal},#{priceoftax},#{billstatus},"
				+ "#{exchrate},#{maker},#{salesid},#{permitter},#{departname},#{projectid})")
		public void addoder(oderfrom od);
		
		//新增从表
		@Insert("insert into test.oderfromcong(billno,ProdId,oldprice,discount,sPrice,squantity,amount,Vftotal,"
				+ "Preindate,Qtyremain,taxrate,taxamt,trantype,fromno)values(#{no},#{prodId},#{oldprice},"
				+ "#{discount},#{sPrice},#{squantity},#{amount},#{vftotal},#{Preindate},#{qtyremain},#{taxrate},#{taxamt},#{trantype},#{fromno})")
		public void addoder1(oderfrom od);
		
		//修改主表的审核状态
		@Update("update oderfrom set Shifoushenhe='已审核' where billno=#{billno}")
		public void updateshzt(@Param("billno")String id);
		
		//修改主表的反审核状态
		@Update("update oderfrom set Shifoushenhe='未审核' where billno=#{billno}")
		public void updateshzt1(@Param("billno")String id);
		
		//修改请购表的单况（审核）
		@Update("update cgqg set billstatus='已结案' where billno=#{billno}")
		public void updateqgdk(@Param("billno")String id);
		
		//修改请购表的单况(反审核)
		@Update("update cgqg set billstatus='未结案' where billno=#{billno}")
		public void updateqgcong(@Param("billno")String id);
		
		//删除主表
		@Delete("delete from oderfrom where billno=#{0}")
		public void deleteoder(String billno);
		
		//删除从表
		@Delete("delete from oderfromcong where billno=#{0}")
		public void deleteodercong(String billno);
 
}
